package com.bd.scm.module.globalParams.controller;


import com.bd.scm.domain.models.globalParams.BdSysGlobalParams;
import com.bd.scm.module.globalParams.BdSysGlobalParamsService;
import com.bd.scm.module.utils.ResultUtil;
import com.bd.utils.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 考勤参数设置-前端控制器
 * </p>
 *
 * @author Mason
 * @since 2020-08-12
 */
@RestController
@RequestMapping("api/bdSysGlobalParams")
public class BdSysGlobalParamsController {


    @Autowired
    private BdSysGlobalParamsService bdSysGlobalParamsService;

    /**
     * 获取考勤配置的参数.
     *
     * @return
     */
    @GetMapping("getConfigData")
    public Result getConfigData() {
        return ResultUtil.ok(bdSysGlobalParamsService.getConfigData());
    }
    /**
     * 保存考勤配置的参数.
     *
     * @return
     */
    @PostMapping("saveKqConfig")
    public Result saveKqConfig(@RequestBody BdSysGlobalParams bdSysGlobalParams) {
        Result result = null;
        try{
            bdSysGlobalParamsService.saveKqConfig(bdSysGlobalParams);
            result = ResultUtil.ok();
        }catch(Exception e){
            e.printStackTrace();
            result = ResultUtil.error("服务器内部错误，请联系管理员。");
        }
        return result;
    }
}

